#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "a.h"

void print_books(struct Books book); //直接传递结构体变量
void print_struct_address(struct Books *book); //直接传递地址

/* 这里其实也是直接传递地址，不过我们在后续新创建一个结构体指针指向这个地址 */
void print_void_struct(void *aaa);

int main(void)
{
	My_Struct_Init();
	print_books(book1);
	print_struct_address(&book1);
	print_void_struct(&book1);
	print_void_struct(NULL);
	return 0;
}

/* 直接传递结构体变量 */
void print_books(struct Books book)
{
	printf("Book title : %s\n", book.title);
	printf("Book author : %s\n", book.author);
	printf("Book subject : %s\n", book.subject);
	printf("Book book_id : %d\n", book.book_id);
	printf("------------------------------\r\n");
}

/* 直接传递地址 */
void print_struct_address(struct Books *book)
{
	printf("Book title : %s\n", book->title);
	printf("Book author : %s\n", book->author);
	printf("Book subject : %s\n", book->subject);
	printf("Book book_id : %d\n", book->book_id);
	printf("------------------------------\r\n");
}

/* 这里其实也是直接传递地址，不过我们在后续新创建一个结构体指针指向这个地址 */
void print_void_struct(void *aaa)
{
	if(aaa != NULL)
	{
		struct Books *book = aaa;
		printf("Book title : %s\n", book->title);
		printf("Book author : %s\n", book->author);
		printf("Book subject : %s\n", book->subject);
		printf("Book book_id : %d\n", book->book_id);
	}
	else
	{
		printf("传递的参数为NULL....\r\n");
	}
	printf("------------------------------\r\n");
}